package com.china08.yxyapi.api.manage.tec.office.attendance;

import java.sql.Time;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.entity.db.attendance.YxyYxyTecAttendanceConfig;
import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.db.attendance.YxyTecAttendanceConfigRepository;

/**
 * 教师考勤--我的考勤--显示需要打卡的时间
 * 
 * @author LiuWeidong
 *
 */
@CrossOrigin
@RestController
public class AttendanceYxyTecAttendanceConfigSrhController extends YxyApiBaseController {

    @Autowired
    private YxyTecAttendanceConfigRepository yxyTecAttendanceConfigRepository;

    @RequestMapping(value = "/api_yw/manage/tec/office/attendance/AttendanceYxyTecAttendanceConfigSrh", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel precess(HttpServletRequest request, HttpServletResponse response) {

        String schoolId = getProfile(request, response).getSchoolId();
        YxyYxyTecAttendanceConfig yxyYxyTecAttendanceConfig = yxyTecAttendanceConfigRepository.findBySchoolId(schoolId);
        RespModel model = new RespModel();
        if (yxyYxyTecAttendanceConfig != null) {
            model.schoolId = yxyYxyTecAttendanceConfig.getSchoolId();
            model.times = yxyYxyTecAttendanceConfig.getTimes();
            model.clock1 = yxyYxyTecAttendanceConfig.getClock1();
            model.clock2 = yxyYxyTecAttendanceConfig.getClock2();
            model.clock3 = yxyYxyTecAttendanceConfig.getClock3();
            model.clock4 = yxyYxyTecAttendanceConfig.getClock4();
            model.clock5 = yxyYxyTecAttendanceConfig.getClock5();
            model.clock6 = yxyYxyTecAttendanceConfig.getClock6();
            model.clock7 = yxyYxyTecAttendanceConfig.getClock7();
            model.clock8 = yxyYxyTecAttendanceConfig.getClock8();
        }
        return model;

    }

    protected static class ReqModel extends YxyApiReqModel {

    }

    protected static class RespModel extends YxyApiRespModel {
        // 学校ID
        public String schoolId;
        // 打卡次数
        public String times;
        // 第一次打卡时间
        public Time clock1;
        // 第二次打卡时间
        public Time clock2;
        // 第三次打卡时间
        public Time clock3;
        // 第四次打卡时间
        public Time clock4;
        // 第五次打卡时间
        public Time clock5;
        // 第六次打卡时间
        public Time clock6;
        // 第七次打卡时间
        public Time clock7;
        // 第八次打卡时间
        public Time clock8;

    }
}
